/**
 * Definition for singly-linked list.
 * function ListNode(val) {
 *     this.val = val;
 *     this.next = null;
 * }
 */
/**
 * @param {ListNode} head
 * @return {ListNode}
 */
 var reverseList = function(head) {
	let prev = null
	let curr = head
	while(curr != null) {
			// 要先保存下一个节点，否则在改变节点时，引用就发生变化了
			const next = curr.next
			curr.next = prev
			prev = curr
			curr = next
	}
	return prev
};